package models.core;

import models.GenericAttr;
import play.data.validation.Constraints;
import play.db.ebean.Model;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: hungdq
 * Date: 4/30/12
 * Time: 4:27 PM
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class BaseAttrSpec extends GipxyModel{
    @Constraints.Required
    public String renderType;//see RenderType.class
    public String name;
    public String duplicatable;

    public static Finder<Long,BaseAttrSpec> find = new Finder<Long,BaseAttrSpec>(Long.class, BaseAttrSpec.class);

    public static Map<String,String> options() {
        LinkedHashMap<String,String> options = new LinkedHashMap<String,String>();
        for(BaseAttrSpec c: BaseAttrSpec.find.orderBy("name").findList()) {
            options.put(c.id.toString(), c.name);
        }
        return options;
    }

    public static List<BaseAttrSpec> attibutes(){
        return  BaseAttrSpec.find.orderBy("name").findList();
    }

    public static Map<String,String> getValueSpace(){
        return options();
    }
}
